import request from '@/utils/request'

const api_name = '/acl/permission'

export default {
  getNestedTreeList() {
    return request({
      url: `${api_name}/getAllPemissions`,
      method: 'get'
    })
  },
  removeById(id) {
    return request({
      url: `${api_name}/deletePermissions?id=${id}`,
      method: "get"
    })
  },
  saveLevelOne(menu) {
    return request({
      url: `${api_name}/save`,
      method: "post",
      data: menu
    })
  },
  update(menu) {
    return request({
      url: `${api_name}/update`,
      method: "put",
      data: menu
    })
  },
  toAssign(roleId) {
    return request({
      url: `${api_name}/getPermissionsByRoleId?roleid=${roleId}`,
      method: 'get'
    })
  },
  doAssign(roleid, permissions) {
    return request({
      url: `${api_name}/saveRolePermission`,
      method: "post",
      params: {roleid, permissions}
    })
  }
}
